package br.ufrgs.ga.listeners;

import java.security.InvalidParameterException;

import br.ufrgs.ga.model.Individual;

public class GenerationInformation {

	private final int generation;
	private final Individual bestIndividual;
	
	public GenerationInformation(int generation, Individual bestIndividual) {
		if (generation < 0) {
			throw new InvalidParameterException("The generation value cannot be less than zero.");
		}
		if (bestIndividual == null) {
			throw new InvalidParameterException("The best individual cannot be null.");
		}
		
		this.generation = generation;
		this.bestIndividual = bestIndividual;
	}

	public synchronized int getGeneration() {
		return generation;
	}

	public synchronized Individual getBestIndividual() {
		return bestIndividual;
	}
	
	public synchronized boolean isValidBestIndividual() {
		return bestIndividual.getFitnessValue() == 0;
	}
}
